import 'package:flutter/material.dart';
import 'model/post.dart';

void main() =>runApp(App());
 

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Home(),
      theme: ThemeData(
        primarySwatch: Colors.yellow
      ),
    );
  }
}

class Home extends StatelessWidget {
  Widget _itemBuilder(BuildContext context ,int index) {
    return Container(
      color: Colors.white,
      margin: EdgeInsets.all(8.0),
      child: Column(
        children: <Widget>[
          Image.network(posts[index].imageUrl,fit:BoxFit.cover),
          SizedBox(height: 20),
          Text(
            posts[index].title,
            style:Theme.of(context).textTheme.title
          ),
          SizedBox(height: 20),
          Text(
            posts[index].author,
            style:Theme.of(context).textTheme.subtitle
          ),
          SizedBox(height: 20),
        ],
      ),
    );
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[100],
        appBar: AppBar(
          title: Text('hello'),
          elevation: 0.0,
        ),
        body: ListView.builder(
          itemCount: posts.length,
          itemBuilder: _itemBuilder,
        ),
      );
  }
}

class Hello extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(
        'hello1',
        textDirection:TextDirection.ltr,
        style: TextStyle(
          fontSize: 40.0
        ),
      ),
    );
  }
}

